using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class NXHANGInfo
    {
		#region Local Variable
		public enum Field
		{
			SOCT,
			LINE,
			LOAICT,
			NGAYCT,
			LOAIHANG,
			LOCATION,
			QUYCACH,
			DVTINH,
			SOLUONG,
			GIAVON,
			GIABAN,
			SOTIEN,
			TINHTRANG,
			XUATKHO
		}
		private String _SOCT;
		private Int32 _LINE;
		private String _LOAICT;
		private DateTime _NGAYCT;
		private String _LOAIHANG;
		private String _LOCATION;
		private String _QUYCACH;
		private String _DVTINH;
		private Double _SOLUONG;
		private Double _GIAVON;
		private Double _GIABAN;
		private Double _SOTIEN;
		private String _TINHTRANG;
		private Boolean _XUATKHO;
		
		public String SOCT{	get{ return _SOCT;} set{_SOCT = value;} }
		public Int32 LINE{	get{ return _LINE;} set{_LINE = value;} }
		public String LOAICT{	get{ return _LOAICT;} set{_LOAICT = value;} }
		public DateTime NGAYCT{	get{ return _NGAYCT;} set{_NGAYCT = value;} }
		public String LOAIHANG{	get{ return _LOAIHANG;} set{_LOAIHANG = value;} }
		public String LOCATION{	get{ return _LOCATION;} set{_LOCATION = value;} }
		public String QUYCACH{	get{ return _QUYCACH;} set{_QUYCACH = value;} }
		public String DVTINH{	get{ return _DVTINH;} set{_DVTINH = value;} }
		public Double SOLUONG{	get{ return _SOLUONG;} set{_SOLUONG = value;} }
		public Double GIAVON{	get{ return _GIAVON;} set{_GIAVON = value;} }
		public Double GIABAN{	get{ return _GIABAN;} set{_GIABAN = value;} }
		public Double SOTIEN{	get{ return _SOTIEN;} set{_SOTIEN = value;} }
		public String TINHTRANG{	get{ return _TINHTRANG;} set{_TINHTRANG = value;} }
		public Boolean XUATKHO{	get{ return _XUATKHO;} set{_XUATKHO = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public NXHANGInfo()
		{
			_SOCT = "";
			_LINE = 0;
			_LOAICT = "";
			_NGAYCT = DateTime.Now;
			_LOAIHANG = "";
			_LOCATION = "";
			_QUYCACH = "";
			_DVTINH = "";
			_SOLUONG = 0;
			_GIAVON = 0;
			_GIABAN = 0;
			_SOTIEN = 0;
			_TINHTRANG = "";
			_XUATKHO = true;
		}
		public NXHANGInfo(
		String SOCT,
		Int32 LINE,
		String LOAICT,
		DateTime NGAYCT,
		String LOAIHANG,
		String LOCATION,
		String QUYCACH,
		String DVTINH,
		Double SOLUONG,
		Double GIAVON,
		Double GIABAN,
		Double SOTIEN,
		String TINHTRANG,
		Boolean XUATKHO
		)
		{
			_SOCT = SOCT;
			_LINE = LINE;
			_LOAICT = LOAICT;
			_NGAYCT = NGAYCT;
			_LOAIHANG = LOAIHANG;
			_LOCATION = LOCATION;
			_QUYCACH = QUYCACH;
			_DVTINH = DVTINH;
			_SOLUONG = SOLUONG;
			_GIAVON = GIAVON;
			_GIABAN = GIABAN;
			_SOTIEN = SOTIEN;
			_TINHTRANG = TINHTRANG;
			_XUATKHO = XUATKHO;
		}
		public NXHANGInfo(DataRow dr)
		{
			if (dr != null)
			{
				_SOCT = dr[Field.SOCT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SOCT.ToString()]);
				_LINE = dr[Field.LINE.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.LINE.ToString()]);
				_LOAICT = dr[Field.LOAICT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.LOAICT.ToString()]);
				_NGAYCT = dr[Field.NGAYCT.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.NGAYCT.ToString()]);
				_LOAIHANG = dr[Field.LOAIHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.LOAIHANG.ToString()]);
				_LOCATION = dr[Field.LOCATION.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.LOCATION.ToString()]);
				_QUYCACH = dr[Field.QUYCACH.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.QUYCACH.ToString()]);
				_DVTINH = dr[Field.DVTINH.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DVTINH.ToString()]);
				_SOLUONG = dr[Field.SOLUONG.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOLUONG.ToString()]);
				_GIAVON = dr[Field.GIAVON.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIAVON.ToString()]);
				_GIABAN = dr[Field.GIABAN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIABAN.ToString()]);
				_SOTIEN = dr[Field.SOTIEN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOTIEN.ToString()]);
				_TINHTRANG = dr[Field.TINHTRANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TINHTRANG.ToString()]);
				_XUATKHO = dr[Field.XUATKHO.ToString()] == DBNull.Value?true:Convert.ToBoolean(dr[Field.XUATKHO.ToString()]);
			}
		}
		public NXHANGInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_SOCT = dr[Field.SOCT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SOCT.ToString()]);
				_LINE = dr[Field.LINE.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.LINE.ToString()]);
				_LOAICT = dr[Field.LOAICT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.LOAICT.ToString()]);
				_NGAYCT = dr[Field.NGAYCT.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.NGAYCT.ToString()]);
				_LOAIHANG = dr[Field.LOAIHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.LOAIHANG.ToString()]);
				_LOCATION = dr[Field.LOCATION.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.LOCATION.ToString()]);
				_QUYCACH = dr[Field.QUYCACH.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.QUYCACH.ToString()]);
				_DVTINH = dr[Field.DVTINH.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DVTINH.ToString()]);
				_SOLUONG = dr[Field.SOLUONG.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOLUONG.ToString()]);
				_GIAVON = dr[Field.GIAVON.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIAVON.ToString()]);
				_GIABAN = dr[Field.GIABAN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIABAN.ToString()]);
				_SOTIEN = dr[Field.SOTIEN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOTIEN.ToString()]);
				_TINHTRANG = dr[Field.TINHTRANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TINHTRANG.ToString()]);
				_XUATKHO = dr[Field.XUATKHO.ToString()] == DBNull.Value?true:Convert.ToBoolean(dr[Field.XUATKHO.ToString()]);
			}
		}
		public NXHANGInfo(NXHANGInfo objEntr)
		{			
			_SOCT = objEntr.SOCT;			
			_LINE = objEntr.LINE;			
			_LOAICT = objEntr.LOAICT;			
			_NGAYCT = objEntr.NGAYCT;			
			_LOAIHANG = objEntr.LOAIHANG;			
			_LOCATION = objEntr.LOCATION;			
			_QUYCACH = objEntr.QUYCACH;			
			_DVTINH = objEntr.DVTINH;			
			_SOLUONG = objEntr.SOLUONG;			
			_GIAVON = objEntr.GIAVON;			
			_GIABAN = objEntr.GIABAN;			
			_SOTIEN = objEntr.SOTIEN;			
			_TINHTRANG = objEntr.TINHTRANG;			
			_XUATKHO = objEntr.XUATKHO;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("NXHANG");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.SOCT.ToString(), typeof(String)),
				new DataColumn(Field.LINE.ToString(), typeof(Int32)),
				new DataColumn(Field.LOAICT.ToString(), typeof(String)),
				new DataColumn(Field.NGAYCT.ToString(), typeof(DateTime)),
				new DataColumn(Field.LOAIHANG.ToString(), typeof(String)),
				new DataColumn(Field.LOCATION.ToString(), typeof(String)),
				new DataColumn(Field.QUYCACH.ToString(), typeof(String)),
				new DataColumn(Field.DVTINH.ToString(), typeof(String)),
				new DataColumn(Field.SOLUONG.ToString(), typeof(Double)),
				new DataColumn(Field.GIAVON.ToString(), typeof(Double)),
				new DataColumn(Field.GIABAN.ToString(), typeof(Double)),
				new DataColumn(Field.SOTIEN.ToString(), typeof(Double)),
				new DataColumn(Field.TINHTRANG.ToString(), typeof(String)),
				new DataColumn(Field.XUATKHO.ToString(), typeof(Boolean))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.SOCT.ToString()] = _SOCT;
			row[Field.LINE.ToString()] = _LINE;
			row[Field.LOAICT.ToString()] = _LOAICT;
			row[Field.NGAYCT.ToString()] = _NGAYCT;
			row[Field.LOAIHANG.ToString()] = _LOAIHANG;
			row[Field.LOCATION.ToString()] = _LOCATION;
			row[Field.QUYCACH.ToString()] = _QUYCACH;
			row[Field.DVTINH.ToString()] = _DVTINH;
			row[Field.SOLUONG.ToString()] = _SOLUONG;
			row[Field.GIAVON.ToString()] = _GIAVON;
			row[Field.GIABAN.ToString()] = _GIABAN;
			row[Field.SOTIEN.ToString()] = _SOTIEN;
			row[Field.TINHTRANG.ToString()] = _TINHTRANG;
			row[Field.XUATKHO.ToString()] = _XUATKHO;
			return row;
		}
        #endregion InitTable
    }
}
